package com.algorithm.sort;

import java.util.Arrays;

/**
 * @author chenqb
 * @version 1.0
 * @description: TODO
 * @date 2021/7/29 17:03
 */
public class SortMethod {
    public static void main(String[] args) {
        int[] ins={1,8,9,3,7,6,};
        insertionSort(ins);
        System.out.println(Arrays.toString(ins));
    }


    /**
     * @description 插入排序
     * @param ins
     * @return void
     * @author chenqb
     * @date 2021/7/29 17:08
     */
    public static void insertionSort(int[] ins){
        for (int i=1;i<ins.length;i++){
            for (int j=i;j>0;j--){
                if (ins[j]<ins[j-1]){
                    int temp=ins[j-1];
                    ins[j-1]=ins[j];
                    ins[j]=temp;
                }
            }
        }
    }
    /**
     * @description 冒泡排序 dataStructure
     * @param array
     * @return void
     * @author chenqb
     * @date 2021/7/29 17:35
     */
    public static void bubbleSort(int[] array){
        int t=0;
        for (int i=0;i<array.length-1;i++){
            for (int j=0;j<array.length-1-i;j++){
                if (array[j]>array[j+1]){
                    t=array[j];
                    array[j]=array[j+1];
                    array[j+1]=t;
                }
            }
        }
    }


}
